﻿using System.Collections.Generic;

namespace Comsenz.Services.Blocks.Models
{
    /// <summary>
    /// 返回的数据
    /// </summary>
    /// <author>Chrion</author>
    public class ResultData
    {
        #region Ctors
        /// <summary>
        /// 构建返回的数据
        /// </summary>
        public ResultData()
        {
        }
        /// <summary>
        /// 构建返回的数据
        /// </summary>
        /// <param name="html">模块内容</param>
        /// <param name="datas">模块数据</param>
        public ResultData(string html, List<DataItem> datas)
        {
            Html = html;
            Datas = datas;
        }
        #endregion Ctors

        #region Props
        /// <summary>
        /// 模块内容
        /// </summary>
        public string Html { get; set; }
        /// <summary>
        /// 模块数据
        /// </summary>
        public List<DataItem> Datas { get; set; }
        #endregion Props


        #region Methods
        /// <summary>
        /// 取得配置值
        /// </summary>
        /// <returns></returns>
        public Dictionary<object, object> GetConfigValue()
        {
            var datas = new Dictionary<object, object>();
            if (Datas != null)
            {
                for (var i = 0; i < Datas.Count; i++)
                {
                    datas.Add(i, Datas[i].GetConfigValue());
                }
            }
            return new Dictionary<object, object>
            {
                {"html",Html},
                {"data",datas}
            };
        }
        #endregion Methods

    }
}
